﻿using Ken_WPF_UI.Model;
using Ken_WPF_UI.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ken_WPF_UI.Data
{
    public static class UserData
    {


        public static List<UserInfo> GetUserList()
        {
            List<UserInfo> userInfos = new List<UserInfo>();
            UserInfo user;
            Random random = new Random();
            for (int i = 0; i < 20; i++)
            {
                user = new UserInfo()
                {
                    UserAge = i < 10 ? i + 6 : Convert.ToInt32(1.5 * i),
                    UserHeight = i < 10 ? 120 + 1.5 * i : 100 + 2 * i,
                    UserLevel = $"等级{i + 1}",
                    UserName = $"李{i + 1}",
                    UserId = new Random().Next(100, 200) + Guid.NewGuid().ToString("N").Substring(0, 6).ToUpper(),
                    DeptId = random.Next(0, 7),
                };
                userInfos.Add(user);
            }

            return userInfos;
        }


        public static List<DeptInfo> GetDeptList()
        {
            List<DeptInfo> deptInfoList = new List<DeptInfo>();
            DeptInfo deptInfo;
            int deptId_;
            for (int i = 0; i < 8; i++)
            {
                deptId_ = i;
                deptInfo = new DeptInfo()
                {
                    DeptId = deptId_,
                    DeptName = GetDeptName(deptId_),
                };
                deptInfoList.Add(deptInfo);
            }

            return deptInfoList;
        }

        private static string GetDeptName(int deptId_)
        {
            string deptName;
            switch (deptId_)
            {
                case 0:
                    deptName = "开发部";
                    break;
                case 1:
                    deptName = "生产部";
                    break;
                case 2:
                    deptName = "采购部";
                    break;
                case 3:
                    deptName = "人事部";
                    break;
                case 4:
                    deptName = "质检部";
                    break;
                case 5:
                    deptName = "售后部";
                    break;   
                case 6:
                    deptName = "财务部";
                    break;
                default:
                    deptName = "销售部";
                    break;
            }

            return deptName;
        }

        public static UserDeptViewModel GetUserDeptViewModelt()
        {
            UserDeptViewModel userDeptView = new UserDeptViewModel();
            userDeptView.UserList = GetUserList();
            userDeptView.DeptList = GetDeptList();
            return userDeptView;
        }
    }
}
